package org.llc.flink.study.example

object HigherOrderFunDemo02 {
  def main(args: Array[String]): Unit = {
    /**
      * 这里返回的fun1就是minusxy里面的匿名函数：(y: Int) => 3 + y
      * 等价于 def fun1 = (y: Int) => 3 + y
      * 所以fun1(6)的结果为9
      * 也可以一步到位：minusxy(3)(6)
      */
    val fun1 = minusxy(3)
    // fun1 = <function1>
    println("fun1 = " + fun1)
    val res = fun1(6)
    // res = 9
    println("res = " + res)

    // minusxy(3)(6) = 9
    println("minusxy(3)(6) = " + minusxy(3)(6))

  }

  def minusxy(x: Int) = {
    // 匿名函数
    (y: Int) => x + y
  }
}
